package com.hjt.frame.panels;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;

import com.hjt.frame.MainFrame;
import com.hjt.frame.event.SyncClickActionEvent;

public class OverwriteFrame extends JFrame{

	public OverwriteFrame(int x, int y, int w, int h) {
		System.out.println(String.format("OverwriteFrame[x[%s],y[%s],w[%s],h[%s]]", x, y, w, h));
		this.setLayout(null);
		this.setUndecorated(true);
		this.setBounds(x, y, w, h);
		this.setOpacity(0.4f);
		this.setAlwaysOnTop(true);
		this.addMouseListener(new ClickEvent(this));
		this.setVisible(true);
	}
	
	class ClickEvent extends MouseAdapter{
		OverwriteFrame frame;
		
		public ClickEvent(OverwriteFrame frame) {
			this.frame = frame;
		}
		
		@Override
		public void mouseClicked(MouseEvent e) {
			int x = e.getX();
			int y = e.getY();
			boolean screenMode = MainFrame.scriptMode.isSelected();
			System.out.println(String.format("OverwriteFrame.mouseClicked[x[%s],y[%s]", x, y));
			if(screenMode) {
				
			}else {
				SyncClickActionEvent.syncClick(x,  y, frame.getWidth(), frame.getHeight());
			}
		}
	}
}
